<?php

namespace App\FrontModule\Presenters;

use App\Model\Dao\Page;

/**
 * Page presenter.
 */
class PagePresenter extends BasePresenter {

  private $page;
  
  /**
   * Default action
   * @param String $link
   */
  public function actionDefault($link = NULL){
    if(!isset($link)){
      $this->redirect('Homepage:default');
    }
    
    $this->page = $this->em->getDao(Page::getClassName())->findOneBy(array('link' => $link));
    
    if(!$this->page){
      $this->redirect('Homepage:default');
    }
  }
  
  /**
   * Default render
   * @param String $link
   */
  public function renderDefault($link = NULL){
    $this->template->page = $this->page;
  }
}
